#include "widget.h"
#include "ui_widget.h"
#include <QFileDialog>
#include <QDebug>
#include <QFileInfo>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    // 弹出文件对话框 + 获取文件属性信息
    QString path = QFileDialog::getOpenFileName(this);
    // 构造QFileInfo对象
    QFileInfo fileInfo(path);

    // 保存属性信息到字符串
    QString labelText;
    labelText += "File Name: " + fileInfo.fileName() + "\n";
    labelText += "File Suffix: " + fileInfo.suffix() + "\n";
    labelText += "File Path: " + fileInfo.path() + "\n";
    labelText += "File Size: " + QString::number(fileInfo.size()) + " bytes\n";
    labelText += "Is File: " + (fileInfo.isFile() ? QString("Yes") : QString("No")) + "\n";
    labelText += "Is Directory: " + (fileInfo.isDir() ? QString("Yes") : QString("No")) + "\n";


    // 设置label的文本内容
    ui->label->setText(labelText);
}

